import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/* Router Modules */
// import componentsRouter from './modules/components'
// import chartsRouter from './modules/charts'
// import tableRouter from './modules/table'
// import nestedRouter from './modules/nested'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */
/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [

  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboar',
    name: 'admin',
    meta: {
      roles: ['all', 'daili', 'qudao'],
      title: '后台站长',
    },
    children: [
      {
        path: 'dashboar',
        component: () => import('@/views/admin/dashboard/index'),
        name: 'Dashboard',
        meta: { roles: ['all', 'daili', 'qudao'], icon: 'dashboard', title: 'uv折线图', affix: true, noCache: true }
      },
      {
        path: 'online',
        hidden: true,
        component: () => import('@/views/admin/online'),
        name: 'Online',
        meta: { roles: ['all'], title: '在线渠道', noCache: true }
      },
      // {
      //   path: 'dosage',
      //   component: () => import('@/views/admin/dosage'),
      //   name: 'Dosage',
      //   meta: { title: '站长补量', icon: 'example', noCache: true }
      // },
      // {
      //   path: 'history',
      //   component: () => import('@/views/admin/history'),
      //   name: 'History',
      //   meta: { title: '补量记录', icon: 'list', noCache: true }
      // },
      // {
      //   path: 'deduction',
      //   component: () => import('@/views/admin/deduction'),
      //   name: 'Deduction',
      //   meta: { title: '站长扣量', icon: 'example', noCache: true }
      // },
      // {
      //   path: 'dhistory',
      //   component: () => import('@/views/admin/dhistory'),
      //   name: 'Dhistory',
      //   meta: { title: '扣量记录', icon: 'list', noCache: true }
      // },
      // {
      //   path: 'online',
      //   hidden: true,
      //   component: () => import('@/views/admin/online'),
      //   name: 'Online',
      //   meta: { title: '在线站长', noCache: true, activeMenu: '/dashboar' }
      // },
      // {
      //   path: 'linechart',
      //   component: () => import('@/views/admin/linechart/index'),
      //   name: 'Linechart',
      //   meta: { title: '站长曲线', icon: 'tree', noCache: true }
      // }
    ]
  },
  {
    path: '/adv',
    component: Layout,
    name: 'config',
    meta: {
      roles: ['all'],
      title: '广告配置',
      icon: 'component'
    },
    children: [
      {
        path: 'config',
        component: () => import('@/views/adv_admin/config'),
        name: 'Dashboard',
        meta: { roles: ['all'], icon: 'dashboard', title: '广告配置', affix: true, noCache: true }
      },
      {
        path: 'template',
        component: () => import('@/views/adv_admin/adv_template'),
        name: 'Dashboard',
        meta: { roles: ['all'], icon: 'dashboard', title: '模板配置', affix: true, noCache: true }
      },
      {
        path: 'id',
        component: () => import('@/views/adv_admin/adv_id'),
        name: 'Dashboard',
        meta: { roles: ['all'], icon: 'dashboard', title: '广告id配置', affix: true, noCache: true }
      },
      {
        path: 'pull',
        component: () => import('@/views/adv_admin/pull_back'),
        name: 'Dashboard',
        meta: { roles: ['all'], icon: 'dashboard', title: '拉回代码配置', affix: true, noCache: true }
      },
      {
        path: 'kouling',
        component: () => import('@/views/adv_admin/kouling'),
        name: 'Dashboard',
        meta: { roles: ['all'], icon: 'dashboard', title: '口令配置', affix: true, noCache: true }
      },
    ]
    },
  {
    path: '/back',
    component: Layout,
    name: 'admin',
    meta: { roles: ['all', 'daili'], title: '回传统计',icon: 'component'},
    children: [
      {
        path: 'tx',
        component: () => import('@/views/admin/TXBackStatistics'),
        name: 'Deduction',
        meta: { roles: ['all', 'daili'], title: '管点通回传统计', icon: 'international', noCache: true }
      },
      {
        path: 'jl',
        component: () => import('@/views/admin/JLBackStatistics'),
        name: 'Deduction',
        meta: { roles: ['all', 'daili'], title: '巨量回传统计', icon: 'international', noCache: true }
      },
      {
        path: 'oppo',
        component: () => import('@/views/admin/OppoBackStatistics'),
        name: 'Deduction',
        meta: { roles: ['all', 'daili'], title: 'oppo回传统计', icon: 'international', noCache: true }
      },
      {
        path: 'vivo',
        component: () => import('@/views/admin/VivoBackStatistics'),
        name: 'Deduction',
        meta: { roles: ['all', 'daili'], title: 'vivo回传统计', icon: 'international', noCache: true }
      },
      {
        path: 'huawei',
        component: () => import('@/views/admin/HuaweiBackStatistics'),
        name: 'Deduction',
        meta: { roles: ['all', 'daili'], title: 'huawei回传统计', icon: 'international', noCache: true }
      },
      {
        path: 'xiaomi',
        component: () => import('@/views/admin/XiaomiBackStatistics'),
        name: 'Deduction',
        meta: { roles: ['all', 'daili'], title: 'xiaomi回传统计', icon: 'international', noCache: true }
      },
    ]
  },
  {
    path: '/report',
    component: Layout,
    name: 'admin',
    meta: {
      roles: ['all', 'daili', 'qudao'],
      title: '数据报表(待修改)',
      icon: 'list'
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/admin/report'),
        name: 'Report',
        meta: { roles: ['all', 'daili', 'qudao'], title: 'uv数据报表', icon: 'list', noCache: true }
      }
      // {
      //   path: 'click',
      //   component: () => import('@/views/admin/advClickReport'),
      //   name: 'Report',
      //   meta: { roles: ['all'], title: '点击类型报表', icon: 'list', noCache: true }
      // },
      
    ]
  },
  // {
  //   path: '/earnings',
  //   component: Layout,
  //   name: 'admin',
  //   meta: {
  //     roles: ['daili', 'qudao'],
  //     title: '收益'
  //   },
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/admin/earnings'),
  //       name: 'Earnings',
  //       meta: { roles: ['daili', 'qudao'], title: '收益管理', icon: 'nested', noCache: true }
  //     },
  //   ]
  // },
  // {
  //   path: '/settle',
  //   component: Layout,
  //   name: 'admin',
  //   meta: {
  //     roles: ['all'],
  //     title: '代理结算',
  //   },
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/admin/settle'),
  //       name: 'Settle',
  //       meta: { roles: ['all'], title: '收益管理', icon: 'list', noCache: true }
  //     },
  //   ]
  // },
  {
    path: '/control',
    component: Layout,
    name: 'admin',
    meta: {
      roles: ['all'],
      title: '代理管理',
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/admin/control'),
        name: 'Control',
        meta: { roles: ['all'], title: '代理管理', icon: 'tree', noCache: true }
      },
    ]
  },
  {
    path: '/channel',
    component: Layout,
    name: 'admin',
    meta: {
      roles: ['daili'],
      title: '站长管理',
    },
    children: [
      {
        path: 'control/channel',
        component: () => import('@/views/admin/control_channel'),
        name: 'Controlqudao',
        meta: { roles: ['daili'], title: '渠道管理', icon: 'list', noCache: true }
      },
    ]
  },
  {
    path: '/qudao',
    component: Layout,
    name: 'admin',
    meta: {
      roles: ['all'],
      title: '站长管理'
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/admin/qudao'),
        name: 'Qudao',
        meta: { roles: ['all'], title: '渠道管理', icon: 'tree-table', noCache: true }
      },
    ]
  },
  {
    path: '/code',
    component: Layout,
    name: 'admin',
    meta: {
      roles: ['qudao'],
      title: '代码',
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/admin/code'),
        name: 'Code',
        meta: { roles: ['qudao'], title: '代码', noCache: true }
      },
    ]
  },
  // {
  //   path: '/deduction',
  //   component: Layout,
  //   name: 'admin',
  //   meta: { roles: ['all'], title: 'UV调整' },
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/admin/deduction'),
  //       name: 'Deduction',
  //       meta: { roles: ['all'], title: 'UV调整', icon: 'international', noCache: true }
  //     },
  //   ]
  // },
  // {
  //   path: '/danjia',
  //   component: Layout,
  //   name: 'admin',
  //   meta: { roles: ['all'], title: '单价计算' },
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/admin/shouyi'),
  //       name: 'Deduction',
  //       meta: { roles: ['all'], title: '单价计算', icon: 'international', noCache: true }
  //     },
  //   ]
  // },
  {
    path: '/analysis',
    component: Layout,
    name: 'admin',
    meta: {
      roles: ['all', 'daili', 'qudao'],
      title: '数据分析',
      icon: 'list'
    },
    children: [
      
      {
        path: 'phone',
        component: () => import('@/views/admin/phoneReport'),
        name: 'Report',
        meta: { roles: ['all'], title: '手机型号', icon: 'list', noCache: true }
      },
      {
        path: 'oaidNull',
        component: () => import('@/views/adv_admin/oaid_null'),
        name: 'Report',
        meta: { roles: ['all'], title: '未获取oaid次数', icon: 'list', noCache: true }
      },
      {
        path: 'pullSource',
        component: () => import('@/views/adv_admin/pull_source'),
        name: 'Deduction',
        meta: { roles: ['all'], title: '拉起源', icon: 'list', noCache: true }
      },
      {
        path: 'dp',
        component: () => import('@/views/admin/DpTypeReport'),
        name: 'Report',
        meta: { roles: ['all'], title: '拉起方式', icon: 'list', noCache: true }
      },
      {
        path: 'pullType',
        component: () => import('@/views/adv_admin/pull_type'),
        name: 'Report',
        meta: { roles: ['all'], title: 'h5拉起详情', icon: 'list', noCache: true }
      },
      {
        path: 'pkgVsrsion',
        component: () => import('@/views/adv_admin/pkg_version'),
        name: 'Report',
        meta: { roles: ['all'], title: '包版本统计', icon: 'list', noCache: true }
      },
      {
        path: 'andoridVsrsion',
        component: () => import('@/views/adv_admin/android_version'),
        name: 'Report',
        meta: { roles: ['all'], title: '安卓版本统计', icon: 'list', noCache: true }
      },
      {
        path: 'usageTime',
        component: () => import('@/views/adv_admin/user_use_time'),
        name: 'Report',
        meta: { roles: ['all'], title: '用户人均时长', icon: 'list', noCache: true }
      },
      {
        path: 'ipError',
        component: () => import('@/views/adv_admin/ip_location_error'),
        name: 'Report',
        meta: { roles: ['all'], title: '获取百度ip位置错误', icon: 'list', noCache: true }
      },
      
    ]
  },
  {
    path: '/error',
    component: Layout,
    name: 'error',
    meta: {
      roles: ['all'],
      title: '广告日志',
      icon: 'component'
    },
    children: [
      {
        path: 'buryingPoint',
        component: () => import('@/views/adv_admin/burying_point'),
        name: 'Dashboard',
        meta: { roles: ['all'], icon: 'dashboard', title: '广告埋点', affix: true, noCache: true }
      },
      {
        path: 'userOaid',
        component: () => import('@/views/adv_admin/user_oaid'),
        name: 'Dashboard',
        meta: { roles: ['all'], icon: 'dashboard', title: '当日用户设备查询', affix: true, noCache: true }
      },
      // {
      //   path: 'report',
      //   component: () => import('@/views/adv_admin/error_report'),
      //   name: 'Dashboard',
      //   meta: { roles: ['all'], icon: 'dashboard', title: '应用错误', affix: true, noCache: true }
      // },
      {
        path: 'adv/info',
        component: () => import('@/views/adv_admin/click_info'),
        name: 'Report',
        meta: { roles: ['all'], title: '广告日志', icon: 'list', noCache: true }
      },
      {
        path: 'show',
        component: () => import('@/views/adv_admin/adv_show_error'),
        name: 'Dashboard',
        meta: { roles: ['all'], icon: 'dashboard', title: '广告展示错误日志', affix: true, noCache: true }
      },
      {
        path: 'request',
        component: () => import('@/views/adv_admin/adv_request_error'),
        name: 'Dashboard',
        meta: { roles: ['all'], icon: 'dashboard', title: '广告请求错误日志', affix: true, noCache: true }
      },
      {
        path: 'advId',
        component: () => import('@/views/adv_admin/adv_id_prepare_show'),
        name: 'Report',
        meta: { roles: ['all'], title: '广告id展示率日志', icon: 'list', noCache: true }
      },
      {
        path: 'template',
        component: () => import('@/views/adv_admin/template_report'),
        name: 'Report',
        meta: { roles: ['all'], title: '广告位点击日志', icon: 'list', noCache: true }
      },
      {
        path: 'advFirstTime',
        component: () => import('@/views/adv_admin/adv_show_time'),
        name: 'Report',
        meta: { roles: ['all'], title: '广告第一次显示时间', icon: 'list', noCache: true }
      }
    ]
    },
  {
    path: '/bl',
    component: Layout,
    name: 'admin',
    meta: { roles: ['all'], title: '规避厂商' ,icon: 'component'},
    children: [
      {
        path: 'city',
        component: () => import('@/views/adv_admin/black_city'),
        name: 'Deduction',
        meta: { roles: ['all'], title: '城市黑名单', icon: 'international', noCache: true }
      },
      {
        path: 'blackpkg',
        component: () => import('@/views/adv_admin/black_install_pkg'),
        name: 'Deduction',
        meta: { roles: ['all'], title: '安装包黑名单', icon: 'international', noCache: true }
      },
      {
        path: 'blackdevice',
        component: () => import('@/views/admin/blicklist'),
        name: 'Deduction',
        meta: { roles: ['all'], title: '设备黑名单', icon: 'international', noCache: true }
      },
      // {
      //   path: 'black',
      //   component: () => import('@/views/adv_admin/black_cut'),
      //   name: 'Deduction',
      //   meta: { roles: ['all'], title: '剪切板敏感词', icon: 'international', noCache: true }
      // },
      // {
      //   path: 'cup',
      //   component: () => import('@/views/admin/cutPlate'),
      //   name: 'Deduction',
      //   meta: { roles: ['all'], title: '剪切板', icon: 'international', noCache: true }
      // },
      {
        path: 'feedback',
        component: () => import('@/views/admin/feedback'),
        name: 'Deduction',
        meta: { roles: ['all'], title: '反馈', icon: 'international', noCache: true }
      },
    ]
  },
 
  {
    path: '/peizhi',
    component: Layout,
    name: 'admin',
    meta: { roles: ['all'], title: '配置',icon: 'component'},
    children: [
      {
        path: 'index',
        component: () => import('@/views/admin/clean'),
        name: 'Clean',
        meta: { roles: ['all'], title: '链接设置', icon: 'component', noCache: true }
      },
      {
        path: 'landing',
        component: () => import('@/views/admin/LandingPage'),
        name: 'Deduction',
        meta: { roles: ['all'], title: '落地页配置', icon: 'international', noCache: true }
      },
      {
        path: 'web/setting',
        component: () => import('@/views/adv_admin/web_setting'),
        name: 'Clean',
        meta: { roles: ['all'], title: '网站设置', icon: 'component', noCache: true }
      },
    ]
  },
  // {
  //   path: '/cnzz',
  //   component: Layout,
  //   redirect: '/cnzz/dashboard',
  //   name: 'Cnzz',
  //   meta: {
  //     roles: ['all'],
  //     title: 'CNZZ(厦门)',
  //     icon: 'component'
  //   },
  //   children: [
      // {
      //   path: 'dashboard',
      //   component: () => import('@/views/cnzz/dashboard/index'),
      //   name: 'Dashboard1',
      //   meta: {roles: ['all'], title: '数据', noCache: true }
      // },
      // {
      //   path: 'report',
      //   component: () => import('@/views/cnzz/report'),
      //   name: 'Cnzzreport',
      //   meta: {roles: ['all'], title: '渠道结算' }
      // },
      // {
      //   path: 'earnings_report',
      //   component: () => import('@/views/cnzz/earnings_report'),
      //   name: 'Cnzzreport',
      //   meta: {roles: ['all'], title: '收益报表' }
      // },
      // {
      //   path: 'cnzz_config',
      //   component: () => import('@/views/cnzz/config'),
      //   name: 'Cnzzreport',
      //   meta: {roles: ['all'], title: '结算配制' }
      // },
      // {
      //   path: 'changshang',
      //   component: () => import('@/views/cnzz/changshang'),
      //   name: 'Cnzzreport',
      //   meta: {roles: ['all'], title: '厂商收益'  }
      // },
      // {
      //   path: 'uvmonitoring',
      //   component: () => import('@/views/cnzz/uv_monitoring_config'),
      //   name: 'Cnzzreport',
      //   meta: {roles: ['all'], title: '点击对比配制'  }
      // },
      // {
      //   path: 'monitoring',
      //   component: () => import('@/views/cnzz/data_monitoring_config'),
      //   name: 'Cnzzreport',
      //   meta: {roles: ['all'], title: '监控配制'  }
      // },
  //     {
  //       path: 'settle',
  //       component: () => import('@/views/cnzz/settle'),
  //       name: 'Settle1',
  //       meta: {roles: ['all'], title: '代理结算', icon: 'chart', noCache: true }
  //     },
  //     {
  //       path: 'deeplink',
  //       component: () => import('@/views/cnzz/deeplink'),
  //       name: 'Deeplink',
  //       meta: {roles: ['all'], title: '拉起查询', icon: 'chart' }
  //     },
  //     {
  //       path: 'javascript/:qudao',
  //       component: () => import('@/views/cnzz/javascript'),
  //       name: 'Javascript',
  //       meta: {roles: ['all'], title: '获取对接代码', noCache: true, activeMenu: '/cnzz/qudao' },
  //       hidden: true
  //     },
  //     {
  //       path: 'clean',
  //       component: () => import('@/views/cnzz/clean'),
  //       name: 'Clean1',
  //       meta: {roles: ['all'], title: '链接设置', icon: 'chart', noCache: true }
  //     },
  //     {
  //       path: 'online',
  //       hidden: true,
  //       component: () => import('@/views/cnzz/online'),
  //       name: 'Online1',
  //       meta: {roles: ['all'], title: '在线站长', noCache: true, activeMenu: '/cnzz/dashboard' }
  //     },
  //     {
  //       path: 'linechart',
  //       component: () => import('@/views/cnzz/linechart/index'),
  //       name: 'Linechart1',
  //       meta: {roles: ['all'], title: '站长曲线', icon: 'chart', noCache: true }
  //     }
  //   ]
  // },
  // {
  //   path: '/book',
  //   component: Layout,
  //   name: 'admin',
  //   meta: {
  //     roles: ['all','daili'],
  //     title: '应用数据',
  //     icon: 'component'
  //   },
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/admin/bookSearch'),
  //       name: 'Code',
  //       meta: { roles: ['all'], title: '书籍查询', noCache: true }
  //     },
  //     {
  //       path: 'detail',
  //       component: () => import('@/views/admin/bookDetail'),
  //       name: 'bookDetail',
  //       hidden: true,
  //       meta: { roles: ['all'], title: '书籍详情', noCache: true }
  //     },
  //     {
  //       path: 'photo',
  //       component: () => import('@/views/admin/photo_author'),
  //       name: 'photo',
  //       meta: { roles: ['all','daili'], title: '图片-作者列表', noCache: true },
  //     },
  //     {
  //       path: 'tupian',
  //       component: () => import('@/views/admin/photo_tupian'),
  //       name: 'tupain',
  //       meta: { roles: ['all','daili'], title: '图片-图片管理', noCache: true },
  //     },
  //   ]
    
  // },
  // {
  //   path: '/fzcnzz',
  //   component: Layout,
  //   redirect: '/cnzz/dashboard',
  //   name: 'Cnzz',
  //   meta: {
  //     roles: ['all'],
  //     title: 'CNZZ(FZ)',
  //     icon: 'component'
  //   },
  //   children: [
  //     {
  //       path: 'fzdashboard',
  //       component: () => import('@/views/cnzz/dashboard/fzindex'),
  //       name: 'Dashboard1',
  //       meta: {roles: ['all'], title: '数据'}
  //     },
  //     {
  //       path: 'fzreport',
  //       component: () => import('@/views/cnzz/fzreport'),
  //       name: 'Cnzzreport',
  //       meta: {roles: ['all'], title: '渠道结算'}
  //     },
  //     {
  //       path: 'fzearnings_report',
  //       component: () => import('@/views/cnzz/fzearnings_report'),
  //       name: 'Cnzzreport',
  //       meta: {roles: ['all'], title: '收益报表'}
  //     },
  //     {
  //       path: 'fzcnzz_config',
  //       component: () => import('@/views/cnzz/fzconfig'),
  //       name: 'Cnzzreport',
  //       meta: {roles: ['all'], title: '结算配制'}
  //     },
  //     {
  //       path: 'changshang',
  //       component: () => import('@/views/cnzz/fz_changshang'),
  //       name: 'Cnzzreport',
  //       meta: {roles: ['all'], title: '厂商收益'  }
  //     },
  //     {
  //       path: 'fzuvmonitoring',
  //       component: () => import('@/views/cnzz/fz_uv_monitoring_config'),
  //       name: 'Cnzzreport',
  //       meta: {roles: ['all'], title: '点击对比配制'  }
  //     },
  //     {
  //       path: 'monitoring',
  //       component: () => import('@/views/cnzz/fzdata_monitoring_config'),
  //       name: 'Cnzzreport',
  //       meta: {roles: ['all'], title: '监控配制'  }
  //     },
  //   ]
  // },
  {
    path: '/reset',
    component: Layout,
    redirect: '/reset/index',
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/views/reset/index'),
        name: 'Reset',
        meta: { title: '修改密码', noCache: true }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }


]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  // base: '/super/',
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
